
//字符串替换
function str_replace(str, val){
    if (Array.isArray(val)) {var idx=0; return str.replace(/\[(.+?)\]/g, function(){return val[idx++];});} //数组
    else {return str.replace(/\[(.+?)\]/g, function(arg,name){return val[name];});} //类
}

//时间戳转换
function formatUnixtimestamp (unixtimestamp1){
    var unixtimestamp = new Date(unixtimestamp1*1000);
    var year = 1900 + unixtimestamp.getYear();
    var month = "0" + (unixtimestamp.getMonth() + 1);
    var date = "0" + unixtimestamp.getDate();
    var hour = "0" + unixtimestamp.getHours();
    var minute = "0" + unixtimestamp.getMinutes();
    var second = "0" + unixtimestamp.getSeconds();
    return year + "-" + month.substring(month.length-2, month.length)  + "-" + date.substring(date.length-2, date.length)
        + " " + hour.substring(hour.length-2, hour.length) + ":"
        + minute.substring(minute.length-2, minute.length) + ":"
        + second.substring(second.length-2, second.length);

}
